//2009/10/25 18:24:44
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <sstream>
#include <algorithm>

using namespace std;

class IsomorphicWords
{
public:
    int countPairs(vector <string> words)
    {
        int count = 0;
        for (int i=0; i<words.size(); i++)
            for (int j=i+1; j<words.size(); j++)
                if (isomorphic(words[i], words[j]))
                {
                    count++;
                    cout << words[i] << ", " << words[j] << endl;
                }
        return count;
    }
    bool isomorphic(string A, string B)
    {
        vector<pair<char, char> > v(A.size());
        for (int i=0; i<A.size(); i++)
        {
            v[i].first = A[i];
            v[i].second = B[i];
        }
        //bool flag = true;
        //cout << v.size() << endl;
        for (int i=0; i<v.size(); i++)
        {
            for (int j=i+1; j<v.size(); j++)
            {
                if (v[i].first == v[j].first && v[i].second != v[j].second)	return false;
                if (v[i].first != v[j].first && v[i].second == v[j].second)	return false;
                //if (v[i].first == v[j].second && v[i].second != v[j].first) return false;
                //if (v[i].first != v[j].second && v[i].second == v[j].first) return false;
            }
        }
        return true;
    }
};
